{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">服务站采购单</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('business.businessorder/add')}"
               data-auth-edit="{:$auth->check('business.businessorder/edit')}"
               data-auth-delete="{:$auth->check('business.businessorder/del')}"
        ></table>
    </div>
</div>
<script type="text/html" id="barTool">

    <a onclick="wk.layer_show('详情','{:url('detail')}?id={{d.id}}',300,true)"
       class="layui-btn layui-bg-cyan layui-btn-xs" title="订单详情">订单详情</a>
    {{# if(d.pay_status==0){ }}
    <a href="javascript:;" onclick="wk.confirm('{{d.id}}','{:url('pay')}','确定后台收款吗？')"
       class="layui-btn layui-btn-danger layui-btn-xs" title="后台收款">后台收款</a>
    {{# } }}

    {{# if(d.status==1){ }}
    <a data-open='{:url("deliver")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('business.businessorder/deliver')?'':'layui-hide'}" title="设置发货">设置发货</a>
    {{# } }}

    {{# if(d.status==3||d.status==2){ }}
    <a data-open='{:url("faDetail")}?id={{ d.id }}' class="layui-btn layui-btn-xs  {:$auth->check('business.businessorder/deliver')?'':'layui-hide'}" title="发货详细">发货详细</a>
    {{# } }}


    {if isset($status)}
    {if $status==1}
    <!--    <a href='{:url("fa")}?id={{ d.id }}'-->
    <!--       class="layui-btn layui-btn-danger layui-btn-xs confirm">确认发货</a>-->
    <!--    <a class="layui-btn layui-btn-sm confirm" data-href='{:url("fa")}?id={{ d.id }}' data-batch-all="currentTable">-->
    <!--        <i class="iconfont icon-right"></i>审核通过</a>-->
    {/if}
    {/if}
    <!--    <a data-open='{:url("detail")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('business.businessorder/detail')?'':'layui-hide'}" title="服务站审核">订单详情</a>&ndash;&gt;-->
    <!--    <a onclick="wk.layer_show('编辑用户','{:url('edit_vip')}?id={{d.u_id}}')" class="layui-btn layui-btn-xs" title="编辑"><i class="fa fa-pencil"></i></a>-->

    <!--    <a href="javascript:;" onclick="wk.confirm('{{d.u_id}}','{:url('del_vip')}')" class="layui-btn layui-btn-danger layui-btn-xs" title="删除"><i class="fa fa-trash-o"></i></a>-->

</script>
<!--<script type="text/html" id="barTool">-->
<!--    <a data-open='{:url("detail")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('business.businessorder/detail')?'':'layui-hide'}" title="服务站审核">订单详情</a>-->
<!--&lt;!&ndash;    <a data-open='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs {:$auth->check('auth.rule/edit')?'':'layui-hide'}" title="编辑"><i class='iconfont icon-brush_fill'></i></a>&ndash;&gt;-->
<!--&lt;!&ndash;    <a href='{:url("del")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('auth.rule/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>&ndash;&gt;-->
<!--</script>-->

<!--操作模板-->

{/block}
{block name="script"}
<script>

    layui.use(['yznTable', 'table'], function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        table.render({
            elem: '#currentTable',
            init: init,
            autoWidth: true,
            // toolbar: ['refresh', [{
            //     html: ' {if $status==1}<a class="layui-btn layui-btn-sm confirm" data-href="{:url("fa")}" data-batch-all="currentTable"><i class="iconfont icon-right"></i>确认发货</a> {/if}',
            //     auth: 'pass',
            toolbar: ['refresh'],
            url: '{:url("index")}?status={$status}',
            // search: false,
            cols: [
                [
                    //订单编号
                    // 所属服务站
                    // 订单金额
                    // 下单时间
                    // 支付时间
                    // 订单状态 '0待支付 1待发货 2已完成 3已发货'
                    // 支付状态 //'支付状态 0未支付1已支付',
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: 50, title: 'ID', search: false},
                    {field: 'order_no', Width: 110, title: '订单编号'},
                    {field: 'business_id', title: '服务站ID', width: 80},
                    {field: 'business_name', Width: 150, title: '所属服务站', search: false},
                    {field: 'price', Width: 120, title: '订单金额', search: false},
                    {field: 'porder_id', Width: 150, title: '发货类型',templet: function (d) {
                            if (d.porder_id == 0) {
                                return '<span style="color: black">整单发货</span>';
                            } else{
                                return '<span style="color: #0000FF">分单发货</span>';
                            } // 订单状态 '0待支付 1待发货 2已完成 3已发货'
                        }, search: false},
                    {
                        field: 'status', Width: 60, title: '订单状态', templet: function (d) {
                            if (d.status == 0) {
                                return '<span style="color: red">待支付</span>';
                            } else if (d.status == 1) {
                                return '<span style="color: orange">待发货</span>';
                            } else if (d.status == 2) {
                                return '<span style="color: green">已完成</span>';
                            } else if (d.status == 3) {
                                return '<span style="color: #0000FF">已发货</span>';
                            } // 订单状态 '0待支付 1待发货 2已完成 3已发货'
                        }, search: false
                    },
                    {
                        field: 'pay_status', Width: 90, title: '支付状态', templet: function (d) {
                            if (d.pay_status == 0) {
                                return '<span style="color: red">未支付</span>';
                            } else {
                                return '<span style="color: green">已支付</span>';
                            }//'支付状态 0未支付1已支付',
                        }, selectList: {0: '未支付', 1: '已支付'},
                    },
                    {
                        field: 'pay_type', Width: 100, title: '支付类型',
                        templet: function (d) {
                            if (d.pay_type == 1) {
                                return '<span style="color: red">余额支付</span>';
                            } else if (d.pay_type == 2) {
                                return '<span style="color: orange">微信支付</span>';
                            } else if (d.pay_type == 3) {
                                return '<span style="color: #0000FF">混合支付</span>';
                            } else if (d.pay_type == 4) {
                                return '<span style="color: #00B83F">后台支付</span>'
                            }else{
                                return '<span>未知</span>'
                            }
                        },//'支付方式 1余额支付 2直接支付 3混合支付'
                        selectList: {1: '余额支付', 2: '直接支付', 3: '混合支付'}
                    },
                    {field: 'fa_time', Width: 150, title: '收货时间', search: false},
                    {field: 'create_time', Width: 150, title: '下单时间', search: 'range'},
                    {field: 'pay_time', Width: 60, title: '支付时间', search: 'range'},

                    // {fixed: 'right', align: 'center', Width: 50, title: '操作',
                    //     toolbar: '#barTool'}//delete'
                    {
                        fixed: 'right', align: 'center', Width: 50, title: '操作',
                        toolbar: '#barTool'
                    }
                ]
            ],
            page: {}
        });
        table.bindevent();
    });
</script>
{/block}